package chuangyi.com.org.ViewModel;

import android.content.Context;
import android.databinding.Bindable;
import android.view.View;

import chuangyi.com.org.DOMIHome.HomeActivity;
import chuangyi.com.org.DOMIHome.LoadingDialog;
import chuangyi.com.org.DOMIHome.Utils.WebApi;
import chuangyi.com.org.DOMIHome.adapter.ListBindingAdapter;

/**
 * Created by zxh on 16/11/25.
 */
public class CollectArticleItem extends ArticleItem {

    private int collectcoun;
    private int collectId;

    @Bindable
    public int getCollectcoun() {
        return collectcoun;
    }

    public void setCollectcoun(int collectcoun) {
        this.collectcoun = collectcoun;
    }

    public int getCollectId() {
        return collectId;
    }

    public void setCollectId(int collectId) {
        this.collectId = collectId;
    }

    public CollectArticleItem(Context context, int layoutId){
        super(context,layoutId);
    }

    public void onClickDelete(View view){
        LoadingDialog.getInstance(getContext()).show();
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(WebApi.removeCollection(getContext(), "w", getArticleId()) != -1){
                    HomeActivity.notifyListChange(ListBindingAdapter.ACTION_DEL, CollectArticleItem.this);
                }
                LoadingDialog.getInstance(getContext()).dismiss();
            }
        }).start();
    }
}
